// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    indicatorDots: "true", //是否显示面板指示点
    autoplay: "true", //是否自动切换
    interval: "5000", //自动切换时间间隔
    duration: "1000", //滑动动画时长
    //中部分类区
    choose:0,//用于分类区文字的变色
    flitrates:[
      {text:"性价比",iconUp:"",iconDown:"unfold",F_direction:0,width:"21%"},
      {text:"单价",iconUp:"fold",iconDown:"unfold",F_direction:0,width:"19%"},
      {text:"时长",iconUp:"fold",iconDown:"unfold",F_direction:0,width:"19%"},
      {text:"发布时间",iconUp:"fold",iconDown:"unfold",F_direction:0,width:"23%"},
    ],
    swiperImgs:[
      {imgSrc:'/pages/img/建议图.jpg',id:1,},
      {imgSrc:'/pages/img/招被试.jpg',id:2,},
      {imgSrc:'/pages/img/招被试2.jpg',id:3,},
    ],
    //目前是静态数据
    lists:[
      {title:'脑电实验',img:'/pages/img/脑电波-有svg.png',location:'星河楼',sex:'男女不限',last:'2',time:'70',money:'50'},
      {title:'网络成瘾调研问卷',img:'/pages/img/问卷-有svg.png',location:'线上',sex:'男女不限',last:'50',time:'10',money:'5'},
      {title:'脑电实验',img:'/pages/img/核磁设备2-有svg.png',location:'星河楼附近',sex:'仅限男生',last:'3',time:'150',money:'120'},
    ]
  },
  F_onClick:function(e){
    console.log(e.currentTarget.dataset.index)


    var index = e.currentTarget.dataset.index
    //非重复点击，点击了新的分类
    if(index!=this.data.choose){
      this.setData({
        ['flitrates[0].F_direction']:0,
        ['flitrates[1].F_direction']:0,
        ['flitrates[2].F_direction']:0,
        ['flitrates[3].F_direction']:0,
        ['flitrates['+(index-1)+'].F_direction']:1,
        choose:index
      })
      return;
    }
    //重复点击
    if(index==this.data.choose){
      //性价比为特例
      if(index==1){
        this.setData({
          choose:0,
          ['flitrates[0].F_direction']:0,
        })
        return;
      }
      //其他三种情况
      if(this.data.flitrates[(index-1)].F_direction==1){
        this.setData({['flitrates['+(index-1)+'].F_direction']:2,})
      }
      else{
        this.setData({['flitrates['+(index-1)+'].F_direction']:0,choose:0})
      }
    }
  },
  //导航图事件
    //点击轮播图
    swiperClick: function (e) {
        var url=''
        wx.navigateTo({
            url: url+"?id="+e.currentTarget.dataset.id,
        })
    },
    //轮播图轮播事件
    swiperChange: function (e) {
        var swiperIndex = e.detail.current
    },
  onLoad() {
    
  },
  
})
